{extend name="layout" /}

{block name="main"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-10">
            <div class="ibox float-e-margins" style="height: 900px;">
                <div class="ibox-title">
                    <h5></h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" name="post-form" id="commentForm" method="post" action="">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">状态</label>
                            <div class="col-sm-8">
                                <div class="radio i-checks">
                                    <label><input type="radio" id="radio" value="1" checked name="status"> <i></i> 显示</label>
                                    <label><input type="radio" value="0" name="status"> <i></i> 隐藏</label>
                                </div>
                                <div id="zyupload" class="zyupload"></div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">站点名称</label>
                            <div class="col-sm-8">
                                <input  name="name" id="name" minlength="6" maxlength="32" type="text" class="form-control" required="" aria-required="true" value="{$info.name.value}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">网站标题</label>
                            <div class="col-sm-8">
                                <input  name="title" id="title" type="text" class="form-control" minlength="1" maxlength="32" required="" aria-required="true" value="{$info.title.value}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">网站描述</label>
                            <div class="col-sm-8">
                                <input  name="description" id="description" type="text" class="form-control" minlength="1" maxlength="32" required="" aria-required="true" value="{$info.description.value}">
                            </div>
                        </div>
                         <div class="form-group">
                            <label class="col-sm-3 control-label">关键词</label>
                            <div class="col-sm-8">
                                <input  name="keywords" id="keywords" type="text" class="form-control" minlength="1" maxlength="32" required="" aria-required="true" value="{$info.keywords.value}">
                            </div>
                        </div>    
                        <div class="form-group">
                            <label class="col-sm-3 control-label">公司地址</label>
                            <div class="col-sm-8">
                                <input  name="address" id="address" type="text" class="form-control" minlength="1" maxlength="32" required="" aria-required="true" value="{$info.address.value}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">公司电话</label>
                            <div class="col-sm-8">
                                <input  name="tel" id="tel" type="text" class="form-control" minlength="1" maxlength="32" required="" aria-required="true" value="{$info.tel.value}">
                            </div>
                        </div>
                        <hr>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">公司LOGO</label>
                            <div class="col-sm-8">
                               <div class="container">
                                    <div class="page-header" style="border-bottom: 0px;">
                                        <form>
                                            <div class="form-group" id="uploadForm" enctype='multipart/form-data'>
                                                <div class="h4"></div>
                                                <div class="fileinput fileinput-new" data-provides="fileinput"  id="exampleInputUpload">
                                                    <div class="fileinput-new thumbnail" style="width: 200px;height: auto;max-height:150px;">
                                                        <img id='picImg' style="width: 100%;height: auto;max-height: 140px;" src="__admin_path__/img/noimage.png" alt="" />
                                                    </div>
                                                    <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"></div>
                                                    <div>
                                                        <span class="btn btn-primary btn-file">
                                                            <span class="fileinput-new">选择文件</span>
                                                            <span class="fileinput-exists">换一张</span>
                                                            <input type="file" name="pic1" id="picID" accept="image/gif,image/jpeg,image/x-png"/>
                                                        </span>
                                                        <a href="javascript:;" class="btn btn-warning fileinput-exists" data-dismiss="fileinput">移除</a>
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <hr>
                        <div class="form-group">
                            <div class="col-sm-2 col-sm-offset-1">
                                <button class="btn btn-primary" target-form="post-form" type="submit" onclick="save()">提交</button>
                                <button class="btn btn-danger" target-form="post-form" type="submit" onclick="return();">返回</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    /**
     * AJAX提交表单
     * @author 陈一中
     * @return {[type]} [description]
     */
        function save(){
            var radio = $("#radio").val();
            var name = $("#name").val();
            var title = $("#title").val();
            var description = $("#description").val();
            var keywords = $("#keywords").val();
            var address = $("#address").val();
            var tel = $("#tel").val();
            var picID = $("#smsCode").val();
            $.ajax({
                url:"/admin/Basic/update_basic.html",
                type:'post',
                dataType:'json',
                data:{radio:radio,name:name,title:title,description:description,keywords:keywords,address:address,tel:tel,picID:picID},
                success:function(res){
                    if(res.status == true){
                        layer.msg(res.info);
                        setTimeout(function(){
                            window.location.href="/Basic/index.html";
                        },1000);
                    }else{
                        layer.msg(res.info);
                    }
                },
                error:function(){
                    layer.alert('服务器繁忙，稍后再试',{icon:5});
                }
            })
        }
</script>
{/block}
        